{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "# This notebook expects that Modin and Ray are installed, e.g. by `pip install modin[ray]`.\n",
    "# For all ways to install Modin see official documentation at:\n",
    "# https://modin.readthedocs.io/en/latest/installation.html\n",
    "import modin.pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "columns_names = [\n",
    "        \"trip_id\", \"vendor_id\", \"pickup_datetime\", \"dropoff_datetime\", \"store_and_fwd_flag\",\n",
    "        \"rate_code_id\", \"pickup_longitude\", \"pickup_latitude\", \"dropoff_longitude\", \"dropoff_latitude\",\n",
    "        \"passenger_count\", \"trip_distance\", \"fare_amount\", \"extra\", \"mta_tax\", \"tip_amount\",\n",
    "        \"tolls_amount\", \"ehail_fee\", \"improvement_surcharge\", \"total_amount\", \"payment_type\",\n",
    "        \"trip_type\", \"pickup\", \"dropoff\", \"cab_type\", \"precipitation\", \"snow_depth\", \"snowfall\",\n",
    "        \"max_temperature\", \"min_temperature\", \"average_wind_speed\", \"pickup_nyct2010_gid\",\n",
    "        \"pickup_ctlabel\", \"pickup_borocode\", \"pickup_boroname\", \"pickup_ct2010\",\n",
    "        \"pickup_boroct2010\", \"pickup_cdeligibil\", \"pickup_ntacode\", \"pickup_ntaname\", \"pickup_puma\",\n",
    "        \"dropoff_nyct2010_gid\", \"dropoff_ctlabel\", \"dropoff_borocode\", \"dropoff_boroname\",\n",
    "        \"dropoff_ct2010\", \"dropoff_boroct2010\", \"dropoff_cdeligibil\", \"dropoff_ntacode\",\n",
    "        \"dropoff_ntaname\", \"dropoff_puma\",\n",
    "    ]\n",
    "parse_dates=[\"pickup_datetime\", \"dropoff_datetime\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "UserWarning: Parameters provided defaulting to pandas implementation.\n",
      "To request implementation, send an email to feature_requests@modin.org.\n"
     ]
    }
   ],
   "source": [
    "df = pd.read_csv('https://modin-datasets.s3.amazonaws.com/trips_data.csv', names=columns_names,\n",
    "                header=None, parse_dates=parse_dates)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>trip_id</th>\n",
       "      <th>vendor_id</th>\n",
       "      <th>pickup_datetime</th>\n",
       "      <th>dropoff_datetime</th>\n",
       "      <th>store_and_fwd_flag</th>\n",
       "      <th>rate_code_id</th>\n",
       "      <th>pickup_longitude</th>\n",
       "      <th>pickup_latitude</th>\n",
       "      <th>dropoff_longitude</th>\n",
       "      <th>dropoff_latitude</th>\n",
       "      <th>...</th>\n",
       "      <th>dropoff_nyct2010_gid</th>\n",
       "      <th>dropoff_ctlabel</th>\n",
       "      <th>dropoff_borocode</th>\n",
       "      <th>dropoff_boroname</th>\n",
       "      <th>dropoff_ct2010</th>\n",
       "      <th>dropoff_boroct2010</th>\n",
       "      <th>dropoff_cdeligibil</th>\n",
       "      <th>dropoff_ntacode</th>\n",
       "      <th>dropoff_ntaname</th>\n",
       "      <th>dropoff_puma</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>2013-08-01 08:14:37</td>\n",
       "      <td>2013-08-01 09:09:06</td>\n",
       "      <td>N</td>\n",
       "      <td>1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2013-08-01 09:13:00</td>\n",
       "      <td>2013-08-01 11:38:00</td>\n",
       "      <td>N</td>\n",
       "      <td>1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>2013-08-01 09:48:00</td>\n",
       "      <td>2013-08-01 09:49:00</td>\n",
       "      <td>N</td>\n",
       "      <td>5</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>2</td>\n",
       "      <td>2013-08-01 10:38:35</td>\n",
       "      <td>2013-08-01 10:38:51</td>\n",
       "      <td>N</td>\n",
       "      <td>1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>2</td>\n",
       "      <td>2013-08-01 11:51:45</td>\n",
       "      <td>2013-08-01 12:03:52</td>\n",
       "      <td>N</td>\n",
       "      <td>1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9995</th>\n",
       "      <td>9881</td>\n",
       "      <td>2</td>\n",
       "      <td>2013-09-29 01:03:48</td>\n",
       "      <td>2013-09-29 01:09:49</td>\n",
       "      <td>N</td>\n",
       "      <td>1</td>\n",
       "      <td>-73.958336</td>\n",
       "      <td>40.820820</td>\n",
       "      <td>-73.953773</td>\n",
       "      <td>40.825195</td>\n",
       "      <td>...</td>\n",
       "      <td>907.0</td>\n",
       "      <td>225.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>Manhattan</td>\n",
       "      <td>22500.0</td>\n",
       "      <td>1022500.0</td>\n",
       "      <td>E</td>\n",
       "      <td>MN04</td>\n",
       "      <td>Hamilton Heights</td>\n",
       "      <td>3802.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9996</th>\n",
       "      <td>9882</td>\n",
       "      <td>2</td>\n",
       "      <td>2013-09-29 03:04:10</td>\n",
       "      <td>2013-09-29 03:09:37</td>\n",
       "      <td>N</td>\n",
       "      <td>1</td>\n",
       "      <td>-73.958824</td>\n",
       "      <td>40.820251</td>\n",
       "      <td>-73.934174</td>\n",
       "      <td>40.853394</td>\n",
       "      <td>...</td>\n",
       "      <td>912.0</td>\n",
       "      <td>271.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>Manhattan</td>\n",
       "      <td>27100.0</td>\n",
       "      <td>1027100.0</td>\n",
       "      <td>E</td>\n",
       "      <td>MN35</td>\n",
       "      <td>Washington Heights North</td>\n",
       "      <td>3801.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9997</th>\n",
       "      <td>9883</td>\n",
       "      <td>2</td>\n",
       "      <td>2013-09-30 16:28:12</td>\n",
       "      <td>2013-09-30 16:56:03</td>\n",
       "      <td>N</td>\n",
       "      <td>1</td>\n",
       "      <td>-73.956100</td>\n",
       "      <td>40.818974</td>\n",
       "      <td>-73.941055</td>\n",
       "      <td>40.789993</td>\n",
       "      <td>...</td>\n",
       "      <td>1318.0</td>\n",
       "      <td>170.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>Manhattan</td>\n",
       "      <td>17000.0</td>\n",
       "      <td>1017000.0</td>\n",
       "      <td>E</td>\n",
       "      <td>MN33</td>\n",
       "      <td>East Harlem South</td>\n",
       "      <td>3804.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9998</th>\n",
       "      <td>9884</td>\n",
       "      <td>2</td>\n",
       "      <td>2013-09-01 13:15:15</td>\n",
       "      <td>2013-09-01 13:23:10</td>\n",
       "      <td>N</td>\n",
       "      <td>1</td>\n",
       "      <td>-73.955345</td>\n",
       "      <td>40.820053</td>\n",
       "      <td>-73.942444</td>\n",
       "      <td>40.841507</td>\n",
       "      <td>...</td>\n",
       "      <td>911.0</td>\n",
       "      <td>251.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>Manhattan</td>\n",
       "      <td>25100.0</td>\n",
       "      <td>1025100.0</td>\n",
       "      <td>E</td>\n",
       "      <td>MN36</td>\n",
       "      <td>Washington Heights South</td>\n",
       "      <td>3801.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9999</th>\n",
       "      <td>9885</td>\n",
       "      <td>2</td>\n",
       "      <td>2013-09-20 07:32:17</td>\n",
       "      <td>2013-09-20 08:01:06</td>\n",
       "      <td>N</td>\n",
       "      <td>1</td>\n",
       "      <td>-73.955353</td>\n",
       "      <td>40.820213</td>\n",
       "      <td>-73.957680</td>\n",
       "      <td>40.765190</td>\n",
       "      <td>...</td>\n",
       "      <td>1758.0</td>\n",
       "      <td>116.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>Manhattan</td>\n",
       "      <td>11600.0</td>\n",
       "      <td>1011600.0</td>\n",
       "      <td>I</td>\n",
       "      <td>MN31</td>\n",
       "      <td>Lenox Hill-Roosevelt Island</td>\n",
       "      <td>3805.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>10000 rows x 51 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      trip_id  vendor_id     pickup_datetime    dropoff_datetime  \\\n",
       "0           1          2 2013-08-01 08:14:37 2013-08-01 09:09:06   \n",
       "1           2          2 2013-08-01 09:13:00 2013-08-01 11:38:00   \n",
       "2           3          2 2013-08-01 09:48:00 2013-08-01 09:49:00   \n",
       "3           4          2 2013-08-01 10:38:35 2013-08-01 10:38:51   \n",
       "4           5          2 2013-08-01 11:51:45 2013-08-01 12:03:52   \n",
       "...       ...        ...                 ...                 ...   \n",
       "9995     9881          2 2013-09-29 01:03:48 2013-09-29 01:09:49   \n",
       "9996     9882          2 2013-09-29 03:04:10 2013-09-29 03:09:37   \n",
       "9997     9883          2 2013-09-30 16:28:12 2013-09-30 16:56:03   \n",
       "9998     9884          2 2013-09-01 13:15:15 2013-09-01 13:23:10   \n",
       "9999     9885          2 2013-09-20 07:32:17 2013-09-20 08:01:06   \n",
       "\n",
       "     store_and_fwd_flag  rate_code_id  pickup_longitude  pickup_latitude  \\\n",
       "0                     N             1               NaN              NaN   \n",
       "1                     N             1               NaN              NaN   \n",
       "2                     N             5               NaN              NaN   \n",
       "3                     N             1               NaN              NaN   \n",
       "4                     N             1               NaN              NaN   \n",
       "...                 ...           ...               ...              ...   \n",
       "9995                  N             1        -73.958336        40.820820   \n",
       "9996                  N             1        -73.958824        40.820251   \n",
       "9997                  N             1        -73.956100        40.818974   \n",
       "9998                  N             1        -73.955345        40.820053   \n",
       "9999                  N             1        -73.955353        40.820213   \n",
       "\n",
       "      dropoff_longitude  dropoff_latitude  ...  dropoff_nyct2010_gid  \\\n",
       "0                   NaN               NaN  ...                   NaN   \n",
       "1                   NaN               NaN  ...                   NaN   \n",
       "2                   NaN               NaN  ...                   NaN   \n",
       "3                   NaN               NaN  ...                   NaN   \n",
       "4                   NaN               NaN  ...                   NaN   \n",
       "...                 ...               ...  ...                   ...   \n",
       "9995         -73.953773         40.825195  ...                 907.0   \n",
       "9996         -73.934174         40.853394  ...                 912.0   \n",
       "9997         -73.941055         40.789993  ...                1318.0   \n",
       "9998         -73.942444         40.841507  ...                 911.0   \n",
       "9999         -73.957680         40.765190  ...                1758.0   \n",
       "\n",
       "      dropoff_ctlabel  dropoff_borocode  dropoff_boroname  dropoff_ct2010  \\\n",
       "0                 NaN               NaN               NaN             NaN   \n",
       "1                 NaN               NaN               NaN             NaN   \n",
       "2                 NaN               NaN               NaN             NaN   \n",
       "3                 NaN               NaN               NaN             NaN   \n",
       "4                 NaN               NaN               NaN             NaN   \n",
       "...               ...               ...               ...             ...   \n",
       "9995            225.0               1.0         Manhattan         22500.0   \n",
       "9996            271.0               1.0         Manhattan         27100.0   \n",
       "9997            170.0               1.0         Manhattan         17000.0   \n",
       "9998            251.0               1.0         Manhattan         25100.0   \n",
       "9999            116.0               1.0         Manhattan         11600.0   \n",
       "\n",
       "     dropoff_boroct2010  dropoff_cdeligibil  dropoff_ntacode  \\\n",
       "0                   NaN                 NaN              NaN   \n",
       "1                   NaN                 NaN              NaN   \n",
       "2                   NaN                 NaN              NaN   \n",
       "3                   NaN                 NaN              NaN   \n",
       "4                   NaN                 NaN              NaN   \n",
       "...                 ...                 ...              ...   \n",
       "9995          1022500.0                   E             MN04   \n",
       "9996          1027100.0                   E             MN35   \n",
       "9997          1017000.0                   E             MN33   \n",
       "9998          1025100.0                   E             MN36   \n",
       "9999          1011600.0                   I             MN31   \n",
       "\n",
       "                  dropoff_ntaname dropoff_puma  \n",
       "0                             NaN          NaN  \n",
       "1                             NaN          NaN  \n",
       "2                             NaN          NaN  \n",
       "3                             NaN          NaN  \n",
       "4                             NaN          NaN  \n",
       "...                           ...          ...  \n",
       "9995             Hamilton Heights       3802.0  \n",
       "9996     Washington Heights North       3801.0  \n",
       "9997            East Harlem South       3804.0  \n",
       "9998     Washington Heights South       3801.0  \n",
       "9999  Lenox Hill-Roosevelt Island       3805.0  \n",
       "\n",
       "[10000 rows x 51 columns]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "def q1(df):\n",
    "    return df.groupby(\"cab_type\")[\"cab_type\"].count()\n",
    "def q2(df):\n",
    "    return df.groupby(\"passenger_count\", as_index=False).mean()[[\"passenger_count\", \"total_amount\"]]\n",
    "def q3(df):\n",
    "    return df.groupby([\"passenger_count\", \"pickup_datetime\"]).size().reset_index()\n",
    "def q4(df):\n",
    "    transformed = pd.DataFrame({\n",
    "        \"passenger_count\": df[\"passenger_count\"],\n",
    "        \"pickup_datetime\": df[\"pickup_datetime\"].dt.year,\n",
    "        \"trip_distance\": df[\"trip_distance\"].astype(\"int64\"),\n",
    "    })\n",
    "    return transformed.groupby([\"passenger_count\", \"pickup_datetime\", \"trip_distance\"])  \\\n",
    "            .size().reset_index().sort_values(by=[\"pickup_datetime\", 0], ascending=[True, False])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "10000"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "q1(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>passenger_count</th>\n",
       "      <th>total_amount</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>18.333333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>15.258850</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>20.332356</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>13.748845</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>19.742688</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>5</td>\n",
       "      <td>14.786221</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>6</td>\n",
       "      <td>15.400085</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   passenger_count  total_amount\n",
       "0                0     18.333333\n",
       "1                1     15.258850\n",
       "2                2     20.332356\n",
       "3                3     13.748845\n",
       "4                4     19.742688\n",
       "5                5     14.786221\n",
       "6                6     15.400085"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "q2(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>passenger_count</th>\n",
       "      <th>pickup_datetime</th>\n",
       "      <th>0</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>2013-08-14 12:07:00</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0</td>\n",
       "      <td>2013-08-14 12:37:00</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0</td>\n",
       "      <td>2013-08-15 00:00:00</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "      <td>2013-08-01 08:14:37</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1</td>\n",
       "      <td>2013-08-01 09:48:00</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9909</th>\n",
       "      <td>6</td>\n",
       "      <td>2013-09-28 18:30:15</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9910</th>\n",
       "      <td>6</td>\n",
       "      <td>2013-09-28 19:57:22</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9911</th>\n",
       "      <td>6</td>\n",
       "      <td>2013-09-29 18:47:29</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9912</th>\n",
       "      <td>6</td>\n",
       "      <td>2013-09-30 02:27:33</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9913</th>\n",
       "      <td>6</td>\n",
       "      <td>2013-09-30 21:31:06</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>9914 rows x 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      passenger_count     pickup_datetime  0\n",
       "0                   0 2013-08-14 12:07:00  1\n",
       "1                   0 2013-08-14 12:37:00  1\n",
       "2                   0 2013-08-15 00:00:00  1\n",
       "3                   1 2013-08-01 08:14:37  1\n",
       "4                   1 2013-08-01 09:48:00  1\n",
       "...               ...                 ... ..\n",
       "9909                6 2013-09-28 18:30:15  1\n",
       "9910                6 2013-09-28 19:57:22  1\n",
       "9911                6 2013-09-29 18:47:29  1\n",
       "9912                6 2013-09-30 02:27:33  1\n",
       "9913                6 2013-09-30 21:31:06  1\n",
       "\n",
       "[9914 rows x 3 columns]"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "q3(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>passenger_count</th>\n",
       "      <th>pickup_datetime</th>\n",
       "      <th>trip_distance</th>\n",
       "      <th>0</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1</td>\n",
       "      <td>2013</td>\n",
       "      <td>0</td>\n",
       "      <td>1991</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "      <td>2013</td>\n",
       "      <td>1</td>\n",
       "      <td>1270</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1</td>\n",
       "      <td>2013</td>\n",
       "      <td>2</td>\n",
       "      <td>853</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>80</th>\n",
       "      <td>5</td>\n",
       "      <td>2013</td>\n",
       "      <td>0</td>\n",
       "      <td>551</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>81</th>\n",
       "      <td>5</td>\n",
       "      <td>2013</td>\n",
       "      <td>1</td>\n",
       "      <td>537</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>77</th>\n",
       "      <td>4</td>\n",
       "      <td>2013</td>\n",
       "      <td>10</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>78</th>\n",
       "      <td>4</td>\n",
       "      <td>2013</td>\n",
       "      <td>11</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>79</th>\n",
       "      <td>4</td>\n",
       "      <td>2013</td>\n",
       "      <td>14</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>102</th>\n",
       "      <td>5</td>\n",
       "      <td>2013</td>\n",
       "      <td>28</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>115</th>\n",
       "      <td>6</td>\n",
       "      <td>2013</td>\n",
       "      <td>14</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>116 rows x 4 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     passenger_count  pickup_datetime  trip_distance     0\n",
       "2                  1             2013              0  1991\n",
       "3                  1             2013              1  1270\n",
       "4                  1             2013              2   853\n",
       "80                 5             2013              0   551\n",
       "81                 5             2013              1   537\n",
       "..               ...              ...            ...   ...\n",
       "77                 4             2013             10     1\n",
       "78                 4             2013             11     1\n",
       "79                 4             2013             14     1\n",
       "102                5             2013             28     1\n",
       "115                6             2013             14     1\n",
       "\n",
       "[116 rows x 4 columns]"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "q4(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%timeit q1(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%timeit q2(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%timeit q3(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%timeit q4(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "license": "http://www.apache.org/licenses/LICENSE-2.0",
  "license_notice": [
   "Licensed to Modin Development Team under one or more contributor license agreements.",
   "See the NOTICE file distributed with this work for additional information regarding",
   "copyright ownership.  The Modin Development Team licenses this file to you under the",
   "Apache License, Version 2.0 (the \"License\"); you may not use this file except in",
   "compliance with the License.  You may obtain a copy of the License at",
   "",
   "    http://www.apache.org/licenses/LICENSE-2.0",
   "",
   "Unless required by applicable law or agreed to in writing, software distributed under",
   "the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF",
   "ANY KIND, either express or implied. See the License for the specific language",
   "governing permissions and limitations under the License."
  ],
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
